package com.rong.creatmodel.factorymodel.simplefactory.orderPizza;

import com.rong.creatmodel.factorymodel.rk_abstractFactory.SimpleFactory;
import com.rong.creatmodel.factorymodel.simplefactory.pizzastore.CheesePizza;
import com.rong.creatmodel.factorymodel.simplefactory.pizzastore.GreekPizza;
import com.rong.creatmodel.factorymodel.simplefactory.pizzastore.Pizza;

import java.util.Scanner;

public class OrderPizza  {
    //构造器
    public OrderPizza(){
        Pizza pizza = null;
        String orderType;//用户输入 订购披萨的类型
        do{
            orderType = getType();
            if (orderType.equals("greek")){
                pizza = new GreekPizza();
                pizza.setName("greek");
            }else if (orderType.equals("cheese")){
                pizza = new CheesePizza();
                pizza.setName("cheese");
            }else {
                break;
            }
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }
        while (true);
    }

    //定义一个方法，可以获取客户希望订购的披萨种类
    private String getType(){
        String orderType = "";
        System.out.println("input pizza type:");
        Scanner scanner = new Scanner(System.in);
        orderType = scanner.next();
        return orderType;
    }
}
